package Date_Calendar;

import java.time.Instant;
import java.util.Date;

public class Example8 {
    public static void main(String[] args) {
        //演示：时间戳Instant类
        //用now()方法获取Instant类的实例化对象
        Instant instant = Instant.now();
        System.out.println(instant);
        System.out.println("=======================");

        //2.Date类静态方法——from方法可以实现Instant ——> Date
        Date date1 = Date.from(instant);
        System.out.println(date1);
        System.out.println("=========================");

        //3.通过Date类对象调用toInstant方法，可以实现Date ——> Instant
        Instant i = date1.toInstant();
        System.out.println(instant);
    }
}
